{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a1547050",
   "metadata": {},
   "source": [
    " #### 元组(tuple)\n",
    " > 1. 它是和list几乎完全一样的序列数据\n",
    " > 2. 它与list不同的地方是，**不可变**（因为不可变，所以几乎没有方法）\n",
    " > 3. 元组的形式：（1,2,3,4,5）对比： 元组是()  列表是[]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9f61e0f5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2021, tm_mon=10, tm_mday=25, tm_hour=11, tm_min=36, tm_sec=28, tm_wday=0, tm_yday=298, tm_isdst=0)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "92fcf8d0",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = \"Ziyin\",\"Yinyin\",\"Juicy\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6be7246e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('Ziyin', 'Yinyin', 'Juicy')"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1b7dbd8c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tuple"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "7aebf76b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.count(\"Ziyin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "b4a8d075",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.index(\"Ziyin\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f2c55806",
   "metadata": {},
   "source": [
    "#### 字典（dict）\n",
    "> 1. 字典的创建方式\n",
    ">> 1.1 直接创建字典，按照字典的结构：{key:value1, key2:value2,......}\n",
    ">> 1.2 dict()创建字典，dict(key1=value1,key2:value2,...}\n",
    ">> 1.3 新建新空字典，然后增加值的方式创建字典\n",
    "> 2. 字典的性质"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "3df4989b",
   "metadata": {},
   "outputs": [],
   "source": [
    "stu_info = {\n",
    "    \"stu10001\":\"Juicy\",\n",
    "    \"stu10002\":\"Para\",\n",
    "    \"stu10003\":\"Lily\"\n",
    "}\n",
    "\n",
    "stu10001 = {\n",
    "    \"name\":\"Juicy\",\n",
    "    \"age\":18,\n",
    "    \"Job\":\"student\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "c295a62a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu10001': 'Juicy', 'stu10002': 'Para', 'stu10003': 'Lily'}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "7e5127c0",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 第二种创建字典的方法\n",
    "# 与第一种的区别：\n",
    "#    1. dict（）VD{}\n",
    "#    2. stu10001 VS“stu10001”、\n",
    "#    3. = VS：\n",
    "stu_info_02 = dict(\n",
    "    stu10001 = \"Para\",\n",
    "    stu10002 = \"Juicy\",\n",
    "    stu10003  = \"Lily\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "8d718f94",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu10001': 'Para', 'stu10002': 'Juicy', 'stu10003': 'Lily'}"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_info_02"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "d4de8806",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 第三种创建字典的方式，新建新空字典，然后增加值的方式创建字典\n",
    "\n",
    "stu_info_03 = {}\n",
    "stu_info_03['stu1001'] = \"Juicy\" # 字典的增加\n",
    "stu_info_03['stu1002'] = \"Para\"\n",
    "stu_info_03['stu1003'] = \"Ziyin\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7933cf19",
   "metadata": {},
   "source": [
    "### week09作业\n",
    "> 1. 请尝试使用和学习字典的方法（必须完成）\n",
    "> 2. 给一组数据，利用字典查询的方式尝试查找指定的数据（尝试完成）"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
